package data.archive;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import data.elements.Category;
import data.elements.Question;
import data.elements.QuestionArchive;

import toolkit.QuestionReader;

public class QuestionDatabase{

	private static QuestionArchive QUESTIONDATABASE=getDatabase();
	
	private static final QuestionArchive getDatabase(){
		if (QUESTIONDATABASE==null){
			try {
				QUESTIONDATABASE=new QuestionReader(new FileInputStream("testfolder\\questions")).getQuestionarchive();
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return QUESTIONDATABASE;
	}
	public static final int getNumberCategories(){
		return getDatabase().size();
	}
	public static final int size(){
		return QUESTIONDATABASE.size();
	}
	public static final Category get(int index){
		return QUESTIONDATABASE.get(index);
	}
	public static final Question getRandomQuestion(){
		return QUESTIONDATABASE.getRandomQuestion();
	}
	public static final int getSelectedCategories(){
		return QUESTIONDATABASE.getSelectedcategories();
	}
	public static final void setSelectedCategories(int selectedcategories){
		QUESTIONDATABASE.setSelectedcategories(selectedcategories);
	}
	public static final void setstatusall(boolean value){
		QUESTIONDATABASE.setstatusall(value);
	}
	public static final void setStatus(int i,boolean value){
		QUESTIONDATABASE.setstatus(i, value);
	}
}
